#!/bin/bash

driver_name="my_char"


function usage {
echo "$0 <driver-name>"
exit 1
}

if [ ! -z "$1" ]; then
    driver_name=$1
else
    usage
fi

echo "Removing stale nodes"
sudo rm -rf /dev/${driver_name}*

# Check if driver already installed
already=`cat /proc/devices | grep $driver_name`
if [ ! -z "$already" ]; then
   echo "Unloading the driver"
   sudo rmmod char
fi



echo "Done removing the driver"


